<%@ page import="org.springframework.web.context.request.SessionScope" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%request.setAttribute("ctx", request.getContextPath());%>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="${ctx}/layui-v2.9.14/css/layui.css">
    <script src="${pageContext.request.contextPath}/layui-v2.9.14/jquery-2.1.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/layui-v2.9.14/layui.js"></script>
    <script src="${pageContext.request.contextPath}/layui-v2.9.14/layui_ext/xmSelect/xm-select.js"></script>
	 <script src="${pageContext.request.contextPath}/layui-v2.9.14/crypto-js.js"></script>

    <title>主页面</title>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black"> 智慧停车平台</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->

        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                <a href="javascript:;">
                    <img src="//unpkg.com/outeres@0.0.10/img/layui/icon-v2.png" class="layui-nav-img">
                   ${user.username}--账户余额:
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:;">Your Profile</a></dd>
                    <dd><a href="javascript:;">Settings</a></dd>
                    <dd><a href="/auth/logout.do">Sign out</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <ul class="layui-nav layui-nav-tree">
            <!--一级菜单-->
            <c:forEach var="m" items="${list}" >

            <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">${m.name}</a>

                    <dl class="layui-nav-child">
                        <!--二级菜单-->
                        <c:forEach var="c" items="${m.children}">
                            <dd><a href="javascript:;" data-url="${c.path}">${c.name}</a></dd>
<%--                            <dd><a href="javascript:;" data-url="/roleList.do">角色管理</a></dd>--%>
<%--                            <dd><a href="javascript:;" data-url="/menuList.do">菜单管理</a></dd>--%>
<%--                            <dd><a href="javascript:;" data-url="/demoUser.do">用户演示</a></dd>--%>
<%--                            <dd><a href="javascript:;" data-url="/demoTree.do">树形演示</a></dd>--%>
                        </c:forEach>

                    </dl>
            </li>
            </c:forEach>

        </ul>

    </div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <blockquote class="layui-elem-quote layui-text">

            </blockquote>
            <div class="layui-card layui-panel">
                <iframe frameborder="0" scrolling="yes" style="width: 100%;height: 100%;" src="" id="mainIframe"></iframe>
            </div>
            <br><br>
        </div>
    </div>
    <div class="layui-footer">
        <!-- 底部固定区域 -->

    </div>
</div>


<script>
    layui.use(function(){
        var element = layui.element;
        element.render('nav');
    });
    //JS

    // 左侧菜单点击事件
    $('.layui-nav-child a').on('click', function () {
        var url = $(this).data('url');
        if (url) {
            $('#mainIframe').attr("src", url);
        }
    });

    // $(function (){
    //    $.get("/menu/list",function (res){
    //        console.log(res)
    //    })
    // })
</script>
</body>
</html>